﻿<style scoped>
  .layui-btn:hover {
  }
</style>
<!-- 正文开始 -->
<div class="layui-fluid" style="padding: 5px;">
    <div class="layui-card" style="box-shadow:none;">
        <div class="layui-card-body" style="padding:0px;">
        	<ul id="BizFlightTree" class="ztree"></ul>
        </div>
    </div>
</div>

<SCRIPT type="text/javascript">


layui.use(['layer','form','table'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
	var form =layui.form;
	var table =layui.table;
	var viewer=globe.viewer;
	var setting = {
		async: {
			enable: true,
			url: "#(ctx)/biz/flight/getAsyncTreeData?sceneId=#(sceneId)",
			autoParam:["id", "name=n", "level=lv"],
			dataFilter: filter,
			type: "get"
		},
		view: {
			expandSpeed:"",
			addHoverDom: addHoverDom,
			removeHoverDom: removeHoverDom,
			selectedMulti: false
		},
		check: {
			enable: false
		},
		edit: {
			enable: false
		},
		callback: {
		}
		
	};
	
	function filter(treeId, parentNode, childNodes) {
		if (!childNodes) return null;
		for (var i=0, l=childNodes.length; i<l; i++) {
			childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
		}
		return childNodes;
	}

	/**
		添加鼠标事件	
	*/
	function addHoverDom(treeId, treeNode) {
		var sObj = $("#" + treeNode.tId + "_span");
		if('root'==treeNode.parentId &&  '0'== treeNode.type && !$("#playForBtn_"+treeNode.tId).length>0){
			var addStr= "<span class='button edit' id='playForBtn_" + treeNode.tId+ "' title='播放' onfocus='this.blur();'></span>";
			addStr += "<span class='button edit' id='suspendForBtn_" + treeNode.tId+ "' title='暂停' onfocus='this.blur();'></span>";
			addStr += "<span class='button edit' id='stopForBtn_" + treeNode.tId+ "' title='停止' onfocus='this.blur();'></span>";
			sObj.after(addStr);
			
			var playBtn = $("#playForBtn_"+treeNode.tId);
			if (playBtn) playBtn.bind("click", function(){
				return false;
			});
			
			var suspendBtn = $("#suspendForBtn_"+treeNode.tId);
			if (suspendBtn) suspendBtn.bind("click", function(){
				return false;
			});
			
			var stopBtn = $("#stopForBtn_"+treeNode.tId);
			if (stopBtn) stopBtn.bind("click", function(){
				return false;
			});
			
		}
		else if('root'!=treeNode.parentId &&  !$("#locationForBtn_"+treeNode.tId).length>0){
			var addStr= "<span class='button edit' id='locationForBtn_" + treeNode.tId+ "' title='定位' onfocus='this.blur();'></span>";
			sObj.after(addStr);
			var locationBtn = $("#locationForBtn_"+treeNode.tId);
			if (locationBtn) locationBtn.bind("click", function(){
				showBizFlightPointEditModel(treeNode);
				return false;
			});
		}
	};
	function removeHoverDom(treeId, treeNode) {
		$("#playForBtn_"+treeNode.tId).unbind().remove();
		$("#suspendForBtn_"+treeNode.tId).unbind().remove();
		$("#stopForBtn_"+treeNode.tId).unbind().remove();
		$("#locationForBtn_"+treeNode.tId).unbind().remove();
	};
	
	$(document).ready(function(){
		$.fn.zTree.init($("#BizFlightTree"), setting);
	});
});
</SCRIPT>